package com.example.studentmag1.controller;


import com.example.studentmag1.entity.Teachers;
import com.example.studentmag1.service.TeachersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author admin
 * @since 2022-01-08
 */
@RestController
@RequestMapping("//teachers")
public class TeachersController {
    @Autowired
    private TeachersService teachersService;
    @GetMapping("/list")
    public List<Teachers> list(){
        return this.teachersService.list();
    }
    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable("id") Integer id){
        return this.teachersService.removeById(id);
    }
    @PutMapping("/insert")
    public boolean insert(@RequestBody Teachers teachers){
        return this.teachersService.saveOrUpdate(teachers);
    }
}

